from django.contrib.auth.models import AbstractUser
from django.db.models import CharField, BooleanField, ForeignKey, SET_NULL


class Users(AbstractUser):
    """继承AbstractUser类"""

    mobile = CharField(max_length=11, unique=True, verbose_name='手机号')  # 手机号
    email_active = BooleanField(default=False, verbose_name='邮箱验证状态')
    default_address = ForeignKey('areas.Address', related_name='users', null=True, blank=True,
                                 on_delete=SET_NULL, verbose_name='默认地址')

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户表'
        verbose_name_plural = verbose_name

    def __str__(self):
        """打印对象时直接打印用户名"""
        return self.username
